/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jps.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vinicio Gomez
 */
@Entity
@Table(name = "horario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Horario.findAll", query = "SELECT h FROM Horario h"),
    @NamedQuery(name = "Horario.findByHorario", query = "SELECT h FROM Horario h WHERE h.horario = :horario")})
public class Horario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "Horario")
    private String horario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "horario")
    private Collection<Carpoollist> carpoollistCollection;

    public Horario() {
    }

    public Horario(String horario) {
        this.horario = horario;
    }

    public String getHorario() {
        return horario;
    }

    public void setHorario(String horario) {
        this.horario = horario;
    }

    @XmlTransient
    public Collection<Carpoollist> getCarpoollistCollection() {
        return carpoollistCollection;
    }

    public void setCarpoollistCollection(Collection<Carpoollist> carpoollistCollection) {
        this.carpoollistCollection = carpoollistCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (horario != null ? horario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Horario)) {
            return false;
        }
        Horario other = (Horario) object;
        if ((this.horario == null && other.horario != null) || (this.horario != null && !this.horario.equals(other.horario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //return "jps.entities.Horario[ horario=" + horario + " ]";
        return horario;
    }
    
}
